execution control

execution order
In most programs, the execution of source lines does not proceed strictly in the order of the source statements.  Execution control statements provide capabilities to alter program flow in several ways.

conventional GOTO
GOTO labelName statements transfer execution to labelName in the same function.  Labels are local, so the same labelName can appear in any number of functions.

computed GOTO
Computed GOTO statements transfer execution to labels whose addresses are contained in variables and arrays of the GOADDR data type.  For example:

  GOTO @goVar
  GOTO @goArray[n]

GOTO @goVar jumps to the address in the GOADDR variable goVar, while GOTO @goArray[n] jumps to the address in element n of array goArray[].  If the address is zero, no GOTO is performed and execution continues with the next statement.

The GOADDRESS() intrinsic loads label addresses into GOADDR variables and arrays as follows:

  goVar = GOADDRESS (labelName)
  goArray[n] = GOADDRESS (labelName)

Computed GOTO statements are most useful when one of a number of actions must be performed based on some variable or condition.  For example, the following code segment uses computed GOTO to jump to one of eight labels whose addresses are in dispatch[] , based on a 3-bit field in variable message:

FUNCTION Process ( message )
  action = message{3, 29}
  GOTO @dispatch[action]
' ...
END FUNCTION